package com.qk.management.web.interceptor;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Author: chouh
 * @DateTime: 2025/10/11 12:14
 * @Description: 拦截器
 * 步骤: 1. 创建拦截器类，实现HandlerInterceptor接口
 * 2. 创建拦截器配置类，实现WebMvcConfigurer接口
 * 3. 在配置类中注册拦截器
 */
@Slf4j
@Component
public class MyInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.info("000000000000000000000000000ddddddddddddddddddddddjjjjjjjjjjjjjjjjj");
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        log.info("000000000000000000000000000ddddddddddddddddddddddjjjjjjjjjjjjjjjjj");
        HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        log.info("000000000000000000000000000ddddddddddddddddddddddjjjjjjjjjjjjjjjjj");
        HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
    }
}
